<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <title>医师审核</title>
    <?php PrintPageHead(); ?>
    <link href="../resource/css/hermes.css" rel="stylesheet">
    <link href="../resource/js/calendar/calendar-blue.css" type="text/css" rel="stylesheet">
    <script src="../resource/js/calendar/calendar.js" type="text/javascript"></script>
    <script src="../resource/js/hermes.js"></script>
    <style type="text/css">
        .divleft{width: 12%; float: left; text-align:left; border-right: solid 1px #d5d5d5; margin-right: 2% }
        .divcenter{width: 12%; float: left; text-align:left; border-right: solid 1px #d5d5d5; margin-right: 2%}

        .divright{ width: 12%; float: left; text-align:left;  margin-right: 2%}
        .position {
            position: absolute;
            display: none;
            z-index: 15;
            width: 400px;
            height: 40px;
            margin: -20px 0 0 -75px;
            padding: 0 10px;
            background: #eee;
            line-height: 2.4;
            cursor:pointer;
        }
    </style>
    <?php
    if (!array_key_exists("公众号ID",$_SESSION)) {
        header("Location:back.php");
    }

    pdo()->beginTransaction();
    $bm=new C后台管理员();
    $act = $_GET['act']==''?1:$_GET['act'];
    $本页面 = 'back.php?state=back9check';
    $未认证医师列表=$bm->get未认证医师列表($act,$_GET['page'],$_GET,$_POST['keywords']);
    if($_POST['ok_page']){
       $cs=$_SERVER["QUERY_STRING"];//获取参数
        $page=stripos($cs,"page=");//page=出现的下标
        $url1=substr($cs,$page,5);//截取返回：page=
        $url2="page=1";
        $url=(!$page)?"page=1":$url;
        $nowpages =empty ($_POST['page'])?1:$_POST['page'];
        $act=empty($act)?"1":$act;
     header("Location:".$本页面."&act=".$act."&page=".$nowpages);
    }
//    if($_POST['daochu']){
//
//      // $未认证医师列表=$bm->get未认证医师列表($act,$_GET['page'],$_GET,$_POST['keywords']);
//       // $res=$bm->daochu($未认证医师列表['result'],"da1");
//        $bm->daochu();
//    }
    if($_POST['状态']) {
        $医师详情id = $_POST['医师详情id'];
        unset($_POST['医师详情id']);
        $sql = "select a.用户id,b.认证,b.openID,b.公众号ID from 医师详情 as a left join 用户 as b on a.用户id = b.id where a.id= $医师详情id";
        $用户id = pdo()->selectOne($sql);
        if( $用户id['认证']!='2'){
            if($_POST['状态'] == '通过'){
                $认证 = pdo()->update('用户',array('认证'=>'3','更新缓存'=>'是'),array('id'=>$用户id['用户id']));
                $infouser1="您已经通过医师审核，可以操作平台的全部功能！";
                $bm->ff发送医师审核文本消息($infouser1,$用户id['openID'],$_POST['状态']);
            }
            if($_POST['状态'] == '待审核'  ){
                $认证 = pdo()->update('用户',array('认证'=>'1','更新缓存'=>'是'),array('id'=>$用户id['用户id']));
            }
            if($_POST['状态'] == '未通过' ){
                $认证 = pdo()->update('用户',array('认证'=>'1','更新缓存'=>'是'),array('id'=>$用户id['用户id']));
                $info = "您因以下原因未通过审核：".$_POST['reason'];
                $bm->ff发送医师审核文本消息($info,$用户id['openID'],$_POST['状态']);
            }
        }
        $医师详情 = pdo()->update('医师详情',array('状态'=>$_POST['状态']),array('id'=>$医师详情id));
     empty($_GET['page'])? header("location:".$本页面."&act=".$act): header("location:".$本页面."&act=".$act."&page=".$_GET['page']);
      //  header("location:".$本页面."&act=".$act."&page=".$page);
    }
    pdo()->commit();
    ?>
</head>
<body>


<div class="container-fluid">
    <?php include_once 'back_header.php'; ?>
    <div class="panel panel-primary">
        <div class="panel-heading text-center"><h3 class="panel-title">医师审核</h3></div>
        <div class="panel-body" style="text-align:center">
            <div style="margin: 0 0 10px 0;text-align:left"><b style="color:#3c763d;font-size: 16px;">姓名查询</b><br/>
                <form action="" method="post">
                    <input type="text" name="keywords" value="<?=$_POST['keywords']?>">&nbsp;&nbsp;
                    <button type="submit"  class="btn btn-default btn-success ">&nbsp;查 询&nbsp;</button></form></div>
            <div style="width: 100%; text-align:right">
           <form action="../daochu.php?id=<?=$act?>" method="post">
               <input type="text" style="width: 60px" name="table_name" placeholder="文件名">
               <input type="date" name="r_time"  />
        <input type="submit" name="daochu"  class="btn btn-default btn-success " value="导出"/></form>

                <a href="<?=$本页面?>&act=1" id="daishen">待审核</a>
                <a href="<?=$本页面?>&act=2" id="weit">未通过</a>
                <a href="<?=$本页面?>&act=3" id="tongg">通过</a>
            </div>
            <div class="panel-group"  id="accordion" role="tablist" aria-multiselectable="true">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <div class="row" style="">
                          <div class="divleft">
                                头像
                            </div>
                            <div class="divcenter">
                                姓名
                            </div>
                           
                            <div class="divcenter">
                                医院
                            </div>
                           
                            <div class="divcenter">
                                区域
                            </div>
                            <div class="divcenter">
                                医师资格证
                            </div>
                            <div class="divcenter">
                                个人简介
                            </div>
                            <div class="divright">
                                操作
                            </div>
                        </div>
                    </div>
                </div>
                <?php foreach($未认证医师列表['result'] as $v){?>
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <div class="row">
                                <div class="divleft">
                                    <?php
                                   // $sql = "select 头像 from 用户 where id = {$v['用户id']}";
                                  //  $头像=pdo()->selectOne($sql);
                                    ?>
                                    <img src="<?=$v['头像']?>" width="80%"  id="" style="cursor:pointer" class="fun"/>
                                    <div class="position" >
                                        <img src="<?=$v['头像']?>" width="100%" id="" class="fun1"/>
                                    </div>
                                </div>
                                <div class="divcenter" style="cursor:pointer" >
                                    <div class="fun"><?php echo mb_substr($v['name'],0,5,'utf-8').'...'?></div>
                                    <div  class="position" class="">
                                        <div class="fun1" style="background: #e2ebf3;color:#000000"><?=$v['name']?></div>
                                    </div>
                                </div>
                              
                                <div class="divcenter" style="cursor:pointer" >
                                    <div class="fun"><?php echo mb_substr($v['医院'],0,5,'utf-8').'...'?></div>
                                    <div  class="position" class="">
                                        <div class="fun1" style="background: #e2ebf3;color:#000000"><?=$v['医院']?></div>
                                    </div>
                                </div>
                               
                                <div class="divcenter" style="cursor:pointer" >
                                    <div class="fun"><?php echo mb_substr($v['区域'],0,5,'utf-8').'...'?></div>
                                    <div  class="position" class="">
                                        <div class="fun1" style="background: #e2ebf3;color:#000000"><?=$v['区域']?></div>
                                    </div>
                                </div>
                                <div class="divcenter" >
                                    <img src="<?=$v['照片']?>" width="20%" class="fun" style="cursor:pointer"/>
                                    <div  class="position">
                                        <img src="<?=$v['照片']?>" width="100%" class="fun1"/>
                                    </div>
                                </div>
                                <div class="divcenter" style="cursor:pointer" >
                                    <div class="fun"><?php echo mb_substr($v['简介'],0,5,'utf-8').'...'?></div>
                                    <div  class="position" class="">
                                        <div class="fun1" style="background: #e2ebf3;color:#000000"><?=$v['简介']?></div>
                                    </div>
                                </div>
                                <div class="divright">
                                    <form action="<?=$本页面?>&page=<?=$_GET['page']?>&act=<?=$act?>" method="post" name="form">
                                        <select name="状态" class="btn_select">
                                            <option value="">请选择</option>
                                            <option value="通过" <?php if($v['状态']=='通过')echo selected; ?>>通过</option>
                                            <option value="未通过"<?php if($v['状态']=='未通过')echo selected; ?>>未通过</option>
                                            <option value="待审核"<?php if($v['状态']=='待审核')echo selected; ?>>待审核</option>
                                        </select>
                                        <input type="hidden" name="医师详情id" value="<?=$v['id']?>"/>
                                        <input type="submit" value="确认"/>
                                    </form>
                                </div>
                                </div>

                            </div>
                        </div>

                <?php }
                if(!$未认证医师列表['result']){
                ?>
                <div class="panel-heading text-center"><h3 class="panel-title">没有数据 !!!</h3></div>
                <?php }?>
            </div>
            <?=$未认证医师列表['show']?>
            <form action="" method="post" id="form1">
                到第
            <input type="number" name="page" style=" width: 50px;"  >页<input id="ok_page" name="ok_page"  type="submit" value="确认">
            </form>
        </div>

    </div>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="../resource/js/jquery-1.11.1.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="../resource/js/bootstrap.min.js"></script>
<script language="JavaScript">
    $(function(){
        $(".btn_select").change(function(){
         var status = $(this).val();
          if(status == '未通过'){
              var str=prompt("认证未通过的原因");
              $(this).append("<input type='hidden' name= 'reason' value='"+str+"'/>");
          }
      });
        $(".fun").click(function(){
            $(this).next("div").show();
        })
        $(".fun1").click(function(){
            $(this).parent("div").hide();
        })
        switch(<?=$act?>){
            case 1:
                $("#daishen").css("color","red");
                break;
            case 2:
                $("#weit").css("color","red");
                break;
            case 3:
                $("#tongg").css("color","red");
                break;
        }
    })

</script>
</body>
</html>